﻿using System;
using System.Threading.Tasks;
using Avalonia.Controls;
using Avalonia.Layout;
using Avalonia.Media;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using SukiUI.Controls;
using SukiUI.MessageBox;
using SukiUI.Toasts;

namespace NewUI.ViewModels;

partial class LogInfoViewModel : ViewModelBase
{

    [ObservableProperty] private string _logText = MyText.text;
    
    [RelayCommand]
    private async Task OpenLongMessageBox(bool useNativeWindow = false)
    {
        
        var result = await SukiMessageBox.ShowDialog(new SukiMessageBoxHost
        {
            Content = MyText.text,
            FooterLeftItemsSource = [
                new SelectableTextBlock
                {
                    VerticalAlignment = VerticalAlignment.Center,
                    FontWeight = FontWeight.Bold,
                    Text = $"Text length: {MyText.text.Length:N}",
                },
            ],
            ActionButtonsPreset = SukiMessageBoxButtons.OK
        }, new SukiMessageBoxOptions
        {
            UseNativeWindow = useNativeWindow
        });
        MainWindow.ToastManager.CreateToast()
            .WithTitle("Dialog Option Clicked")
            .WithContent($"You clicked option: {result}")
            .Dismiss().ByClicking()
            .Dismiss().After(TimeSpan.FromSeconds(3))
            .Queue();
    }
        
}

class MyText
{
   public static string text = """"
                   ====================================================================================================
                   EXTREMELY LONG RAW STRING LITERAL DEMONSTRATION
                   ====================================================================================================
                   This C# 11+ raw string literal showcases both extensive vertical length (many lines) and substantial
                   horizontal width (long lines). The triple-quote syntax (""") allows for clean representation of complex
                   multi - line content without escape sequences while preserving all formatting exactly as written.

                   SECTION 1: VERTICAL EXPANSION(MANY LINES)
                   ----------------------------------------------------------------------------------------------------
                   Line 001: This is the first of many lines that demonstrate vertical expansion in a raw string literal.
                   Line 002: Each line is preserved exactly as written, with all whitespace maintained faithfully.
                   Line 003: No need for string concatenation or environment.newline - just type your content naturally.
                   Line 004: The compiler handles all the line breaks and formatting exactly as you see it in the code.
                   Line 005: This makes maintaining long text blocks much easier than traditional string approaches.
                   Line 006: Imagine documenting an entire API specification directly in your code as a string constant.
                   Line 007: Or embedding complete HTML templates with perfect formatting preservation.
                   Line 008: The possibilities are endless for documentation, templates, or data storage in code.
                   Line 009: Raw string literals eliminate the pain of escaped quotes and special characters.
                   Line 010: They're particularly valuable for regular expressions with many backslashes.
                   Line 011: Writing file paths becomes trivial - no more doubling up backslashes.
                   Line 012: JSON, XML, HTML, and other markup languages can be embedded cleanly.
                   Line 013: SQL queries with complex formatting maintain their readability.
                   Line 014: Multi - language support becomes simpler with preserved special characters.
                   Line 015: The text editor scrollbar is getting smaller as we add more lines.
                   Line 016: Yet the code remains perfectly readable and maintainable.
                   Line 017: Each new line adds to the vertical expansion demonstration.
                   Line 018: Notice how the closing delimiter determines indentation handling.
                   Line 019: Common indentation is automatically removed from all lines.
                   Line 020: But relative indentation within the content is preserved.

                   SECTION 2: HORIZONTAL EXPANSION(WIDE CONTENT)
                   ----------------------------------------------------------------------------------------------------
                   This portion demonstrates extremely long lines that extend far to the right, pushing the boundaries of horizontal space in the raw string literal.The line wraps in your editor, but in the actual string, it's preserved as a single, continuous line without breaks (unless explicitly included). Imagine embedding a minified JavaScript file or a very long base64-encoded string - this is where raw string literals shine for horizontal content.

                   EXAMPLE OF EXTREMELY LONG LINE: Lorem ipsum dolor sit amet, consectetur adipiscing elit.Nullam auctor, nisl eget ultricies tincidunt, nisl nisl aliquam nisl, eget ultricies nisl nisl eget nisl.Nullam auctor, nisl eget ultricies tincidunt, nisl nisl aliquam nisl, eget ultricies nisl nisl eget nisl.This line continues with more nonsense text to demonstrate horizontal expansion in raw string literals.The quick brown fox jumps over the lazy dog.Pack my box with five dozen liquor jugs.How vexingly quick daft zebras jump!

                   SECTION 3: COMBINED EXPANSION(BOTH DIRECTIONS)
                   ----------------------------------------------------------------------------------------------------
                   Line 001: Now we combine both approaches with many lines that each contain substantial horizontal content.
                   Line 002: This line contains a long horizontal expansion: The art of raw string literals lies in their ability to handle both dimensions of text expansion gracefully, without compromising readability in the source code or requiring awkward escape sequences that plague traditional string representations.
                   Line 003: Another wide line: In C# 11 and later, raw string literals provide a powerful tool for embedding complex text content directly in your code while maintaining perfect fidelity to the original formatting and structure, whether that content spans vertically, horizontally, or both.
                   Line 004: Wide content: When generating code or text programmatically, raw string literals can serve as perfect templates, containing placeholders that can be replaced at runtime while keeping all the surrounding formatting intact and perfectly readable in the source code.
                   Line 005: Both dimensions: The vertical expansion allows for clear separation of logical sections, while horizontal expansion accommodates content that needs to remain unbroken, such as long URLs, cryptographic keys, or minified resources.

                   SECTION 4: PRACTICAL APPLICATIONS
                   ----------------------------------------------------------------------------------------------------
                   1.EMBEDDED DOCUMENTATION:
                       /// This entire documentation block could be stored in a raw string literal
                       /// with perfect formatting preserved, including all the indentation and
                       /// special characters that would normally require escaping.

                       2.COMPLEX REGULAR EXPRESSIONS:
                      @"^(([^<>()[\]\\.,;:\s@""]+(\.[^<>()[\]\\.,;:\s@""]+)*)|("".+""))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$"
                      (The above complex email regex is much more readable in a raw string literal)

                   3.DATA TEMPLATES:
                       {
                           "templateName": "Invoice",
                          "version": "1.2.3",
                          "fields": [
                              { "name": "invoiceNumber", "type": "string", "required": true},
                              { "name": "customerName", "type": "string", "required": true},
                              { "name": "items", "type": "array", "required": true}
                          ]
                      }

                       4.MULTI - LANGUAGE CONTENT:
                       Bonjour! Это тестовое сообщение.こんにちは！This shows how raw strings handle Unicode.

                    SECTION 5: CONCLUSION
                    ----------------------------------------------------------------------------------------------------
                   This massive raw string literal demonstrates both vertical and horizontal expansion capabilities in C#.
                   The content can grow in either direction without compromising readability or requiring escape sequences.
                   Raw string literals are particularly valuable for:
                   -Embedded resources and templates
                   - Complex regular expressions
                   - Multi - line documentation
                   - Preserving formatting in code generation
                   - Internationalization content
                   - Any scenario where text fidelity matters

                   ====================================================================================================
                   END OF MASSIVE RAW STRING LITERAL DEMONSTRATION
                   ====================================================================================================
                   """";
}